package com.itheima.consumer.controller;


import com.itheima.pojo.User;
import com.itheima.service.userService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class userController {

    @Reference
    private userService userService;

    @GetMapping("/findAll")
    public List<User> findAll(Model model) {
        List<User> list = userService.list();
        model.addAttribute("list",list);
        return list;
    }


    @RequestMapping("/deleteUserById/{id}")
    public boolean deleteUserById(@PathVariable("id") Long id){

       return userService.removeById(id);
    }

    @RequestMapping("/insertUser")
    public boolean insertUser(User user){

        return  userService.save(user);
    }


}
